<%@page import="com.tiantian.domain.Businessstore"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE>
<html>
<head>
<style type="text/css">
.update {
	font-size: 12px;
	padding-left: 15px;
	color: #0033FF;
}

.treeli {
	list-style: none;
}

.firstli {
	padding-top: 7px;
}
</style>
<script src="<c:url value='/static/jquery/jquery-1.9.1.min.js'/>"
	type="text/javascript"></script>
<script type="text/javascript"
	src="<c:url value='/static/common/uc_message.js'/>"></script>
<!-- validate -->
<link rel="stylesheet" href="<c:url value='/static/themes/bootstrap/bootstrapValidator.min.css'/>" />
<script type="text/javascript" src="<c:url value='/static/themes/bootstrap/bootstrapValidator.min.js'/>"></script>
<title>角色详情</title>
</head>
<body>
	<div class="col-lg-12">
		<div id="message"></div>
		<div class="panel panel-default bk-bg-white">
			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form class="form-horizontal" id="roleForm">
							<div class="panel panel-default">
								<div class="panel-heading">
									<input type="hidden" name="id" value="${role.id }">
									<c:choose>
										<c:when test="${empty role.id }">
											<div class="form-group">
												<div class="col-sm-5">
													<label class="control-label"><code style="">*&nbsp;</code>角色名称:</label>
													<input type="text" class="form-control" name="name"
														placeholder="角色名称">
												</div>
											</div>
										</c:when>
										<c:otherwise>
											<h4>角色：<span class="label label-warning">${role.name }</span></h4>
										</c:otherwise>
									</c:choose>
									
								</div>
								<div class="panel-body">
									<ul class="nav nav-pills nav-stacked nav-bracket">
										<li class="firstli">
											<div class="ckbox ckbox-warning">
												<input type="checkbox" id="check1" name="check1"
													${empty auth["check1"]?"":"checked='checked'" }> <label for="check1">审核申请管理</label>
											</div>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-warning">
												<input type="checkbox" id="check2" name="check2"
													${empty auth["check2"]?"":"checked='checked'" }> <label for="check2">用户管理</label>
											</div>
											<ul>
												<li class="treeli"><div class="ckbox ckbox-warning">
														<input type="checkbox" id="check3" name="check3"
															${empty auth["check3"]?"":"checked='checked'" }> <label for="check3">-商家账户管理</label>
													</div></li>
												<li class="treeli"><div class="ckbox ckbox-warning">
														<input type="checkbox" id="check4" name="check4"
															${empty auth["check4"]?"":"checked='checked'" }> <label for="check4">-买手账户管理</label>
													</div></li>
											</ul>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-warning">
												<input type="checkbox" id="check5" name="check5"
													${empty auth["check5"]?"":"checked='checked'" }> <label for="check5">任务管理</label>
											</div>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-warning">
												<input type="checkbox" id="check6" name="check6"
													${empty auth["check6"]?"":"checked='checked'" }> <label for="check6">订单管理</label>
											</div>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-warning">
												<input type="checkbox" id="check7" name="check7"
													${empty auth["check7"]?"":"checked='checked'" }> <label for="check7">申述管理</label>
											</div>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-warning">
												<input type="checkbox" id="check8" name="check8"
													${empty auth["check8"]?"":"checked='checked'" }> <label for="check8">资金管理</label>
											</div>
											<ul>
												<li class="treeli"><div class="ckbox ckbox-warning">
														<input type="checkbox" id="check9" name="check9"
															${empty auth["check9"]?"":"checked='checked'" }> <label for="check9">-平台资金管理</label>
													</div></li>
												<li class="treeli"><div class="ckbox ckbox-warning">
														<input type="checkbox" id="check10" name="check10"
															${empty auth["check10"]?"":"checked='checked'" }> <label for="check10">-商家充值管理</label>
													</div></li>
												<li class="treeli"><div class="ckbox ckbox-warning">
														<input type="checkbox" id="check11" name="check11"
															${empty auth["check11"]?"":"checked='checked'" }> <label for="check11">-买手体现管理</label>
													</div></li>
												<li class="treeli"><div class="ckbox ckbox-warning">
														<input type="checkbox" id="check12" name="check12"
															${empty auth["check12"]?"":"checked='checked'" }> <label for="check12">-管理员人工划款</label>
													</div></li>
											</ul>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-warning">
												<input type="checkbox" id="check13" name="check13"
													${empty auth["check13"]?"":"checked='checked'" }> <label for="check13">消息中心</label>
											</div>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-warning">
												<input type="checkbox" id="check14" name="check14"
													${empty auth["check14"]?"":"checked='checked'" }> <label for="check14">公告管理</label>
											</div>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-default">
												<input type="checkbox" id="check15" name="check15"
													${empty auth["check15"]?"":"checked='checked'" } disabled="disabled"> <label for="check15">权限管理</label>
											</div>
										</li>
										<li class="firstli">
											<div class="ckbox ckbox-default">
												<input type="checkbox" id="check16" name="check16"
													${empty auth["check16"]?"":"checked='checked'" } disabled="disabled"> <label for="check16">操作日志</label>
											</div>
										</li>
									</ul>
								</div>
								<!-- panel-body -->
								<div class="panel-footer">
									<div class="form-group " style="text-align: center;">
										<button type="button" id="unsave"
											class="btn btn-default btn-sm" style="width: 150px">取消</button>
										<button type="button" id="save" class="btn btn-warning btn-sm"
											style="width: 150px">保存</button>
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$(function($) {
			//联动效果
			$('.firstli > .ckbox :checkbox').click(function() {
				var childBoxs = $(this).parent().next('ul').find(':checkbox');
				if ($(this).is(':checked')) {
					childBoxs.attr("checked", true);
				} else {
					childBoxs.attr("checked", false);
				}
				return true;
			});
			//保存
			$('#save').click(function() {
				$('#roleForm').bootstrapValidator('validate');
			});
			
			//验证框架
			$('#roleForm').bootstrapValidator({
				message : '这个值未通过验证',
				feedbackIcons : {
					valid : 'glyphicon glyphicon-ok',
					invalid : 'glyphicon glyphicon-remove',
					validating : 'glyphicon glyphicon-refresh'
				},
				fields : {
					name : {
						validators : {
							notEmpty: {
		                        message: '登录账号是必须的不能为空'
		                    },
		                    stringLength: {
		                        max: 30,
		                        message: '登录账号长度在1-30位'
		                    }
						}
					},
				}
			}).on('success.form.bv', function(e) {
				$.blockUI({ message: '加载中...' });
				$.ajax({
					type : "post",
					url : path + "/auth/role/roleUpdate",
					cache : false,
					data : $('#roleForm').serialize(),
					dataType : "json",
					success : function(data) {
						showmessage(data.msg, function() {
							if (data.success) {
								window.location.href = path + "/auth/role/index";
							}else{
								$.unblockUI();
							}
						});
					}
				});
			});

			//取消
			$('#unsave').click(function() {
				window.location.href = path + "/auth/role/index";
			});
			 
			//显示消息
			function showmessage(msg, callback, msgId) {
				if (msgId) {
					$('#' + msgId).ucMessage({
						msg : msg,
						callback : callback
					});
				} else {

					$('#message').ucMessage({
						msg : msg,
						callback : callback
					});
				}
			} 
		});
	</script>
</body>

</html>